﻿using System;
using System.Text.RegularExpressions;

namespace Needle.Utils.Extensions
{
    /// <summary>
    /// String extension Methods
    /// </summary>
    public static class StringExtensions
    {

        /// <summary>
        /// Replaces the format item in the string with the text equivalent
        /// of the value of a corresponding System.Object instance in a specified array.
        /// </summary>
        public static string FormattedWith(this string format, params object[] args)
        {
            if (format == null)
                throw new NullReferenceException();
            return String.Format(format, args);
        }
        /// <summary>
        /// Replaces the format item in the string with the text equivalent
        /// of the value of a corresponding System.Object instance in a specified array.
        /// </summary>
        public static string FormattedWith(this string format, object arg)
        {
            if (format == null)
                throw new NullReferenceException();
            return String.Format(format, arg);
        }
        /// <summary>
        /// Replaces the format item in the string with the text equivalent
        /// of the value of a corresponding System.Object instance in a specified array.
        /// </summary>
        public static string FormattedWith(this string format, object arg0, object arg1)
        {
            if (format == null)
                throw new NullReferenceException();
            return String.Format(format, arg0,arg1);
        }
        /// <summary>
        /// Replaces the format item in the string with the text equivalent
        /// of the value of a corresponding System.Object instance in a specified array.
        /// </summary>
        public static string FormattedWith(this string format, object arg0, object arg1, object arg2)
        {
            if (format == null)
                throw new NullReferenceException();
            return String.Format(format, arg0, arg1, arg2);
        }
         /// <summary>
        /// Replaces the format item in the string with the text equivalent
        /// of the value of a corresponding System.Object instance in a specified array.
        /// </summary>
        public static string FormattedWith(this string format, IFormatProvider provider, params object[] args)
        {
            if (format == null)
                throw new NullReferenceException();
            return String.Format(provider, format, args);
        }
        /// <summary>
        /// Searches this string for all occurrences of 
        /// the regular expression specified in the pattern parameter.
        /// </summary>
        public static bool IsMatch(this string input, string pattern)
        {
            if (input == null)
                throw new NullReferenceException();
            return Regex.IsMatch(input, pattern);
        }
        /// <summary>
        /// Searches this string for all occurrences of 
        /// the regular expression specified in the pattern parameter.
        /// </summary>
        public static bool IsMatch(this string input, string pattern, RegexOptions  options)
        {
            if (input == null)
                throw new NullReferenceException();
            return Regex.IsMatch(input, pattern, options);
        }
    
    }
}
       